
;; Last modified: 02/15/11, TPEB -- Output IDL save file contains
;;                                  semi-major and semi-minor axis
;;                                  sizes to be compatible with the
;;                                  distance-omnibus code.

fn = 'ancillary/peretto_fuller_table1.dat'

nline = file_lines(fn)

print,nline

openr,lun,fn,/get_lun


pf_irdc = replicate( create_struct('name','','l',0.,'b',0.,'I_min',0.,$
                                   'I_mir',0.,'del_I',0.,'maj',0.,'min',0.,$
                                   'pa_irdc',0,'r_eq',0.,'tau_peak',0.,$
                                   'tau_av',0.,'tau_sat',0.,'frag',0,$
                                   'field_24',0b,'irdc_24',0b,'sigma_24',0.), $
                     nline)



FOR i=0L, nline-1 DO BEGIN

   line = string('')
   readf,lun,line
   
   ;; Read in RA / Dec and convert to Galactic Coordinates
   ra   = tpeb_dms2deg(strmid(line,23,2)+':'+strmid(line,26,2)+':'+$
                       strmid(line,29,5),/RA)
   dec  = tpeb_dms2deg(strmid(line,35,1)+strmid(line,37,2)+':'+$
                       strmid(line,40,2)+':'+strmid(line,43,4))
   euler,ra,dec,l,b,1
   
   pf_irdc[i].name     = strmid(line,9,13)
   pf_irdc[i].l        = l
   pf_irdc[i].b        = b
   pf_irdc[i].i_min    = float(strmid(line,48,6))
   pf_irdc[i].i_mir    = float(strmid(line,55,6))
   pf_irdc[i].del_i    = float(strmid(line,62,5))
   pf_irdc[i].maj      = float(strmid(line,68,6)) / 2.d
   pf_irdc[i].min      = float(strmid(line,75,6)) / 2.d
   pf_irdc[i].pa_irdc  = fix(round(TRANSFORM_POSANG($
                         float(strmid(line,82,4)),ra,dec,1)))
   pf_irdc[i].r_eq     = float(strmid(line,87,6))
   pf_irdc[i].tau_peak = float(strmid(line,94,5))
   pf_irdc[i].tau_av   = float(strmid(line,100,5))
   pf_irdc[i].tau_sat  = float(strmid(line,106,5))
   pf_irdc[i].frag     = fix(strmid(line,112,3))
   CASE strmid(line,116,1) OF
      'y': pf_irdc[i].field_24 = 1b
      'n': pf_irdc[i].field_24 = 0b
   ENDCASE
   CASE strmid(line,118,1) OF
      'y': pf_irdc[i].irdc_24 = 1b
      'n': pf_irdc[i].irdc_24 = 0b
   ENDCASE
   pf_irdc[i].sigma_24 = float(strmid(line,120,5))

   
ENDFOR


save,pf_irdc,filename='irdc_full_data.sav',/ver

close,lun
free_lun,lun

END
